(function() {
    angular.module('app').component('manageModelDataComponent', {
        templateUrl: 'app/controllers/manage.controller/model.component/model.data.component/model.data.component.html',
        controller: manageModelDataComponent,
        controllerAs: 'vm'
    });

    manageModelDataComponent.$inject = ['atomicNotifyService', 'manageModelDataComponentService', '$rootScope', '$timeout'];

    function manageModelDataComponent(atomicNotifyService, manageModelDataComponentService, $rootScope, $timeout) {

        var vm = this;

        vm.$onInit = _init;

        // pagination
        vm.pages = {
            pageCount: 100,
            currentPage: 0,
            onPageChange: function() {
                console.log(this.currentPage);
            }
        };




        
        vm.bars = [{
            text: '综合',
            click: function() {

                if(this.text === '综合'){

                    this.text = "综合排序";

                    console.log(this);

                    vm.bars.init(this);

                }                
            }

        },{
            text: '销量',
            click: function() {

                if(this.text === '销量'){

                    this.text = "销量从低到高";

                    vm.bars.init(this);

                }else if(this.text === "销量从低到高"){

                    this.text = "销量从高到低";

                    vm.bars.init(this);

                }else{
                    this.text = "销量从低到高";

                    vm.bars.init(this);
                }

                
            }

        },{
            text: '人气',
            click: function() {

                if(this.text === '人气'){

                    this.text = "人气从低到高";

                    vm.bars.init(this);

                }else if(this.text === "人气从低到高"){

                    this.text = "人气从高到低";

                    vm.bars.init(this);

                }else{
                    this.text = "人气从低到高";

                    vm.bars.init(this);
                }

                
            }

        }, {
            type: 'dropdown',
            text: '价格',
            icon: 'fa fa-angle-down',
            show: false,
            menu_item: [{
                text: '价格从低到高',
                value: 'taobao',
                icon: ''
            }, {
                text: '价格从高到低',
                value: 'taobao',
                icon: ''
            }],
            onSelect: function(item,event) {

                console.log('select:');

                this.text = item.text;

                alertM(item.text);

                this.show = false;

                event.stopPropagation();
                event.preventDefault();
            },
            click: function() {
                this.show = !this.show;
            }

        }, {

            type: 'dropdown',
            text: '全网',
            name: 'shopType',
            class: 'clearfix',
            icon: 'fa fa-angle-down',
            show: false,
            menu_item: [{
                text: '全网',
                value: 'taobao',
                icon: ''
            }, {
                text: '淘宝',
                value: 'taobao',
                icon: ''
            }, {
                text: '天猫',
                value: 'taobao',
                icon: ''
            }, {
                text: '全球购',
                value: 'taobao',
                icon: ''
            }, {
                text: '天猫过几',
                value: 'taobao',
                icon: ''
            }],

            onSelect: function(item,event) {

                console.log('select:');

                this.text = item.text;

                alertM(item.text);

                this.show = false;

                event.stopPropagation();
                event.preventDefault();
            },
            click: function() {
                this.show = !this.show;
            }
        }];

        

        function alertM(text) {
            console.log(text);
        }



        function _init() {



            //manageModelDataComponentService.get().then(function(data){},function(err){});
        }

    }
})();
